package com.qf.springcloud.item.controller;

import com.qf.springcloud.item.pojo.Item;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/items")
public class ItemController {

    private int count;

    @GetMapping("/item/{id}")
    public Item getItemById(@PathVariable Integer id, HttpServletRequest request){
        System.err.println(request.getRemoteAddr());
        count++;
        System.err.println(count);
        Item item = new Item();
        item.setId(id);
        item.setCategory("生活用品");
        item.setName("打气筒");
        item.setPrice(10000);
        return item;
    }
}
